package bam.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import bam.dao.AreaDao;
import bam.entity.Area;

public class AreaDaoImpl extends HibernateDaoSupport implements AreaDao {

	public int selectAreaNum() throws Exception {
		SQLQuery query = this.getSession().createSQLQuery("select count(id) from area");
		String uniqueResult = query.uniqueResult().toString();
		return Integer.parseInt(uniqueResult);
	}

	public List<Area> selectArea() throws Exception {
		Query query = this.getSession().createQuery("from Area");
		List<Area> list = query.list();
		return list;
	}

	public Area selectAreaOne(int areaid) throws Exception {
		Area area = this.getHibernateTemplate().get(Area.class,areaid);
		return area;
	}
}
